<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
	<head>
	    <title>首页</title>
	    <link href="${ctx}/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
        <link href="${ctx}/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />

        <script src="${ctx}/lib/jquery/jquery-1.9.0.min.js"></script>
        <script src="${ctx}/lib/ligerUI/js/ligerui.all.js"></script>
        <script>
            //var thisTabId = parent.window.tab.getSelectedTabItemID();
            var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)

            $(function() {
                $("#form1").ligerForm();

                //console.log(dialog.get('id'));
                //dialog.hide();
                //parent.window.frames.reload();
            });

            function save()
                 {
                     var form = new liger.get("form1");
                     var data = form.getData();

                     //alert(JSON.stringify(data));

                     $.ajax({
                        type: "post",
                        url: "${ctx}/upload.action",
                        data: {
                            json: JSON.stringify(data)
                        },
                        success: function(data) {
                            console.log(data.code);

                            if (data.code == 200) {

                                $.ligerDialog.success("保存成功");
                                setTimeout(function() {

                                    parent.window.frames.reload(); //调用父窗口方法
                                    dialog.close(); //调用父对话框方法
                                }, 200);
                            }

                        },
                        error: function(e) {
                            alert(e);
                            dialog.close();
                        }
                     });
                 }

                 function setData()
                 {
                     var obj = {
                         firstName: "abc",
                         lastName: "gfg"

                     };
                     var form = new liger.get("form1");
                     form.setData(obj);
                 }


                 function submitForm()
                 {

                     var data = {};
                     $("input,select,textarea").each(function ()
                     {
                         var name = $(this).attr("name");
                         if (name && name.indexOf('ligerui') == -1)
                         {
                             data[name] = this.value;
                         }
                     });
                     alert(JSON.stringify(data));

                 }

        </script>

        <style type="text/css">
                   body{ font-size:12px;}
                .l-table-edit {}
                .l-table-edit-td { padding: 4px;}
                .l-button-submit, .l-button-reset { width:80px; float:left; margin-left:10px; padding-bottom:2px;}
                .l-verify-tip { left:230px; top:120px;}
        </style>
	</head>
	<body style="padding:10px;">

	    <form name="form1" method="post" id="form1">


                <table cellpadding="0" cellspacing="0" class="l-table-edit" >
                    <tr>
                        <td align="right" class="l-table-edit-td">名字:</td>
                        <td align="left" class="l-table-edit-td"><input name="firstName" value="${person.firstName}" type="text" id="first" ltype="text" /></td>
                        <td align="left"></td>
                    </tr>
                    <tr>
                        <td align="right" class="l-table-edit-td">姓氏:</td>
                        <td align="left" class="l-table-edit-td"><input name="lastName" value="${person.lastName}" type="text" id="last" ltype="text" /></td>
                        <td align="left"></td>
                    </tr>
                    <tr>
                        <td align="right" class="l-table-edit-td" valign="top">性别:</td>
                        <td align="left" class="l-table-edit-td">
                            <input id="rbtnl_1" type="radio" name="sex" value="" checked="checked" /><label for="rbtnl_1">男</label>
                            <input id="rbtnl_0" type="radio" name="sex" value="" /><label for="rbtnl_0">女</label>
                        </td><td align="left"></td>
                    </tr>

                    <%--<tr>
                        <td align="right" class="l-table-edit-td" valign="top">爱好:</td>
                        <td align="left" class="l-table-edit-td">
                             <input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" checked="checked" /><label for="CheckBoxList1_0">篮球</label><br /><input id="CheckBoxList1_1" type="checkbox" name="CheckBoxList1$1" /><label for="CheckBoxList1_1">网球</label> <br /><input id="CheckBox1" type="checkbox" name="CheckBoxList1$1" /><label for="CheckBoxList1_1">足球</label>
                        </td><td align="left"></td>
                    </tr>--%>

                    <tr>
                        <td align="right" class="l-table-edit-td">入职日期:</td>
                        <td align="left" class="l-table-edit-td">
                            <input name="txtDate" type="text" id="txtDate" ltype="date" />
                        </td><td align="left"></td>
                    </tr>
                    <tr>
                        <td align="right" class="l-table-edit-td">年龄:</td>
                        <td align="left" class="l-table-edit-td">
                            <input name="txtAge" type="text" id="txtAge" ltype='spinner' ligerui="{type:'int'}" value="20" />
                        </td><td align="left"></td>
                    </tr>
                    <%--<tr>
                        <td align="right" class="l-table-edit-td">部门:</td>
                        <td align="left" class="l-table-edit-td">
                        <select name="ddlDepart" id="ddlDepart" ltype="select" >
        	                <option value="1">主席</option>
        	                <option value="2">研发中心</option>
        	                <option value="3">销售部</option>
        	                <option value="4">市场部</option>
        	                <option value="5">顾问组</option>
                        </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="l-table-edit-td">地址:</td>
                        <td align="left" class="l-table-edit-td">
                        <textarea cols="100" rows="4" class="l-textarea" style="width:400px"></textarea>
                        </td><td align="left"></td>
                    </tr>--%>
                </table>
                <br/>
            </form>
	</body>
</html>
